#include <bits/stdc++.h>
using namespace std;
int main(void){
    int t,a,b,c;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&a,&b,&c);
        int i=1000;
        for(;i<=9999;i++){
            if(i%a==0 && (i+1)%b==0 && (i+2)%c==0){
                printf("%d\n",i);
                break;
            }
        }
        if(i==10000){
            printf("Impossible\n");
            continue;
        }
    }
    return 0;
}